Check
Check[expr,failexpr] evaluates expr, and returns the result, unless messages were generated, in which case it evaluates and returns failexpr.
Check[expr,failexpr,{s1::t1,s2::t2,…}] checks only for the specified messages.
Check[expr,failexpr,"name"] checks only for messages in the named message group.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.